package com.yh.controller;

import com.yh.service.RIBordService;
import com.yh.service.impl.RBordService;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class RBordServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out=response.getWriter();
        String title=request.getParameter("keyword");
        if (title!=""){
            RIBordService ibs=new RBordService();
            JSONArray jsa =ibs.getKey(title);
            System.out.println(jsa);
            out.print(jsa);
        }else {
            out.print("");
        }


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       doGet(req,resp);
    }
}
